package com.inspur

import org.apache.spark.{SparkConf, SparkContext}

object PortraitSaler { // 计算商户画像

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
      //      .setMaster("spark://192.168.66.88:7077")
      .setMaster("local")
      .setAppName("portrait")
    val sc = new SparkContext(conf)

    val products = sc.textFile("hdfs://192.168.66.88:8020/0616/clear_data/products/part-00000")
    val products_result = products
      .map(x => x.split("\t"))
      .map(element=>(element(2), element(1)))
      .reduceByKey(_+_)
      .map(x => x._1 + "\t" + x._2)

    products_result.saveAsTextFile("hdfs://192.168.66.88:8020/0616/portrait")
  }

}
